using Microsoft.AspNetCore.Http;
using System.Collections.Generic;

namespace DbFactory.Base
{
    public class MockHttpContext
    {
        private static IHttpContextAccessor _httpContextAccessor;

        public static void Initialize()
        {
            var httpContext = new DefaultHttpContext();
            httpContext.Items = new Dictionary<object, object>();
            _httpContextAccessor = new HttpContextAccessor
            {
                HttpContext = httpContext
            };
        }

        public static void SetTenant(string tenant)
        {
            if (_httpContextAccessor?.HttpContext == null)
            {
                Initialize();
            }
            _httpContextAccessor.HttpContext.Items["tenant"] = tenant;
        }

        public static IHttpContextAccessor GetHttpContextAccessor()
        {
            if (_httpContextAccessor == null)
            {
                Initialize();
            }
            return _httpContextAccessor;
        }
    }
} 